let http = uni.$u

const BASE_URL = 'http://10.3.0.91:38080'

const install = (e) => {
	http.http.setConfig({
		baseUrl: BASE_URL,
	})
	let vkGlobalThis = vk.getGlobalObject();
	if (typeof vkGlobalThis == "object") vkGlobalThis.api = createApi();
}
// pageNum, pageSize
const createApi = () => ({
	// 微信登录
	wxLogin: params => http.get(`/auth/wx/user/loginAndGetPhone`, params)
	// 服务协议 和 隐私政策
	, getAgreement: params => http.get(`/system/agreement/getAgreement`, params)
	// 获取用户信息
	, getUserInfo: params => http.get(`/system/user/getInfo`, params)
	// 全局搜索书籍
	, globalSearch: params => http.get(`/book/book/globalSearch`, params)
	// 搜索历史记录
	, searchHistory: params => http.get(`/book/book/getSearchHistory`, params)
	//浏览数自增
	, addBrowseNum: params => http.post(`/book/book/addBrowseCount/` + params.bookId,)
	// 书籍详情
	, getBookDetail: params => http.get(`/book/book/index/getBookInfo?`, params)
	// 收藏书籍
	, collectBook: params => http.post(`/book/collection`, params)
	// 书籍目录
	, getBookCatalog: params => http.get(`/book/directory/getDirectoryInfoByBookId/${params.bookId}`, params)
	// 购买书籍
	, buyBook: params => http.post(`/order/order/createOrder`, params)
	// 微信支付
	, wxPay: params => http.post(`/order/order/wxPayTrade`, params, { 'content-type': 'application/x-www-form-urlencoded' })
	// 获取出版社
	, getPublisher: params => http.get(`/book/press/getPressPcListAll`, params)
	// 获取下级 
	, getSubordinate: params => http.get(`/book/category/getCategory/` + params.value)
	// 出版社获取下级
	, getPressSubordinate: params => http.get(`/book/category/getCategory/` + params.value,)
	// 获取书籍列表
	, getBookList: params => http.post(`/book/book/getBookCategoryIndex`, params,)
	// 我的订单
	, getMyOrder: params => http.get(`/order/order/getMyOrderList`, params)
	// 浏览记录
	, getBrowseRecord: params => http.get(`/book/book/getBooksHistory`, params)
	// 收藏书籍列表
	, getCollectBookList: params => http.get(`/book/collection/listByPage`, params)
	// 我的书架
	, getMyBookShelf: params => http.get(`/order/order/getOrderBooklist`, params)
	// 阅读报告
	, getReadReport: params => http.get(`/book/record/getMyBookRecord?`, params)
	// 获取出版社
	, getPress: params => http.get(`/book/press/getPressById`, params)
	// 首页轮播
	, getHomeBanner: params => http.get(`book/banner/listAll`, params)
	// 获取精选书籍
	, getSelectedBook: params => http.get(`/book/book/selectedBooks`, params)
	// 获取最新发布书籍
	, getNewBook: params => http.get(`/book/book/newEwtBook`, params)
	// 获取阅读排行
	, getReadRank: params => http.get(`/book/book/browseTOP`, params)
	// 获取专区
	, getArea: params => http.get(`/book/zone/listAll`, params)
	// 查询专区书籍
	, getAreaBook: params => http.get(`/book/book/selectBooksByZoneId/` + params.zoneId, params)
	//  随机专区列表
	, getRandomArea: params => http.get(`/book/book/getBooksFromRandomZone`, params)
	// 搜索历史记录
	, searchHistory: params => http.get(`/book/app/serach/latelySearch`, params)
	// 清空历史记录
	, clearHistory: params => http.get(`/book/app/serach/removeAll`, params)
	// 出版社下书籍列表
	, getPressBookList: params => http.get(`/book/book/getPressPcListAll/ByPressId`, params)
	// 获取书籍详情
	, getBookInfo: params => http.get(`/book/book/` + params.bookId)
	// 获取目录详情
	, getCatalogInfo: params => http.get(`/book/content/` + params.directoryId)
	// 获取所有分类
	, getAllCategory: params => http.get(`/book/category/listAll`, params)
	// 获取联系方式列表
	, getContactList: params => http.get(`/system/contactUs/listToPC`, params)
	// 获取拓展资源类型
	, getExtendType: params => http.get(`/book/source/getChooseMap`, params)
	// 获取书籍资源章节
	, getBookChapter: params => http.get(`/book/source/list`, params)
	// 获取拓展资源列表
	, getExtendList: params => http.get(`/book/source/listOutSource`, params)
	// 获取测验列表
	, getTestList: params => http.post(`/book/examination/selectExamList`, params)
	// 获取习题列表
	, getExerciseList: params => http.get(`/book/examination/getEntireExam/` + params.examinationId, params)
	// 获取习题字典
	, getExerciseDic: params => http.get(`system/dict/data/type/practice_type`, params)
	// 获取笔记列表
	, getNoteList: params => http.get(`/book/mark/getMarkList`, params)
	// 编辑单个笔记
	, editNote: params => http.put(`/book/mark`, params)
	// 删除单个笔记
	, deleteNote: params => http.delete(`/book/mark/` + params.markId, params)
	// 上传图片  
	, uploadImage: params => http.post(`/file/upload`, params, { 'Content-Type': 'multipart/form-data' })
	// 获取学习报告
	, getStudyReport: params => http.get(`/book/record/getStudyRep`, params)
	// 删除单个谈论
	, deleteDiscuss: params => http.delete(`/book/discuss/` + params.discussId, params)
	// 回复评论列表
	, getDiscussList: params => http.get(`/book/discuss/findAllList`, params)
	// 获取回复列表
	, getReplyList: params => http.get(`/book/reply/findReplyListByDiscuss`, params)
	// 回复评论
	, replyDiscuss: params => http.post(`/book/reply`, params)
	// 提交意见反馈
	, submitFeedback: params => http.post(`/system/feedback/save`, params)
	// 获取消息列表
	, getMessageList: params => http.get(`/system/dpMessage/getMsgListByUserId`, params)
	// 购书码兑换
	, exchangeCode: params => http.post(`/order/redeemCode/activeRedeemCodeSingle`, params, { 'Content-Type': 'application/x-www-form-urlencoded' })
})
export default install